package Pay;

import java.util.HashMap;
import java.util.Map;

public class PayStrategy {
    public static final String ALI_PAY = "AliPay";
    public static final String JD_PAY = "JdPay";
    public static final String UNION_PAY = "UnionPay";
    public static final String WECHAT_PAY = "WechatPay";
    public static final String DEAFAULT_PAY = ALI_PAY;
    private static Map<String,Payment> payStrategy= new HashMap<String,Payment>();
    static {
        payStrategy.put(ALI_PAY,new AliPay());
        payStrategy.put(WECHAT_PAY,new WechatPay());
        payStrategy.put(UNION_PAY,new UnionPay());
        payStrategy.put(JD_PAY,new JDPay());
    }

    public static Payment get(String paykey){
        if(!payStrategy.containsKey(paykey)){
            return payStrategy.get(DEAFAULT_PAY);
        }
        return payStrategy.get(paykey);
    }
}
